<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * all contains only one class with no implementation, only a collection of
 * regular expressions as constants
 *
 * PHP versions 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 *
 * @category   Parsing
 * @package    Rebank
 * @author     Kanazawa Kazuyoshi <kazu.php@gmail.com>
 */

// {{{ Rebank 

/**
 * A collection of regular expressions tested and ready for use
 *
 * rebank stands for regular expression bank and it contains no
 * implementation but a full collection of common regular expressions that
 * are ready to use encapsulated in a class constants
 *
 * PHP versions 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 * @category   Parsing
 * @package    Rebank
 * @author     Kanazawa Kazuyoshi <kazu.php@gmail.com>
 * @copyright   2007 Kazuyoshi Tlacaelel
 * @version    CVS: $Id: rebank.class.php 69 2008-02-17 10:22:54Z kazu.php $
 */
class Rebank
{

    /**
     * matches any valid RFC-standard email address RFC2822 and RFC1035
     *
     */
    const EMAIL =
        '/^([A-Za-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\}\|\~]+|"([\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x0-\x7F])*")(\.([A-Za-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\}\|\~]+|"([\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x0-\x7F])*"))*@([A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])?)*|(1[0-9]{0,2}|2([0-4][0-9]?|5[0-4]?|[6-9])?|[3-9][0-9]?)(\.(0|1[0-9]{0,2}|2([0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?)){2}\.(1[0-9]{0,2}|2([0-4][0-9]?|5[0-4]?|[6-9])?|[3-9][0-9]?))$/';

    /**
     * url
     *
     */
    const URL =
        '/(?#WebOrIP)((?#protocol)((http|https):\/\/)?(?#subDomain)(([a-zA-Z0-9]+\.(?#domain)[a-zA-Z0-9\-]+(?#TLD)(\.[a-zA-Z]+){1,2})|(?#IPAddress)((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])))+(?#Port)(:[1-9][0-9]*)?)+(?#Path)((\/((?#dirOrFileName)[a-zA-Z0-9_\-\%\~\+]+)?)*)?(?#extension)(\.([a-zA-Z0-9_]+))?(?#parameters)(\?([a-zA-Z0-9_\-]+\=[a-z-A-Z0-9_\-\%\~\+]+)?(?#additionalParameters)(\&([a-zA-Z0-9_\-]+\=[a-z-A-Z0-9_\-\%\~\+]+)?)*)?/';

    /**
     * html link
     *
     */
    const HTML_LINK = 
        '/<a[\s]+[^>]*?href[\s]?=[\s\"\']*([^"\'\s]+)[\"\']*.*?>([^<]+|.*?)?<\/a>/';
        /* 
           '/<a[\s]+[^>]*?href[\s]?=[\s\"\']*(.*?)[\"\']*.*?>([^<]+|.*?)?<\/a>/';
         */

    /**
     * html metatag
     *
     * Captures :
     *  -   name attribute of the HTML metatag tag
     *  -   content attribute of the HTML metatag tag
     */
    const HTML_METATAG = 
        '/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+(.*?)[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/';

    /**
     * html colors
     *
     */
    const HTML_COLOR = '/^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$/';


    /**
     * ip table
     */
    const IP_METATABLE =
        '/^(?<Date>.+\s\d+\s\d+\:\d+\:\d+).+\:.+\:(?<Traffic>.+)\:(?<Rule>.+)\:IN\=(?<InboundInterface>.+)\sOUT\=(?<OutboundIntercace>.*?)\s(?:MAC\=(?<MacAddress>.+)\s|)SRC\=(?<Source>.+)\sDST\=(?<Destination>.+)\sLEN\=.+TOS\=.+PROTO\=(?<Protocol>.+)\sSPT\=(?<SourcePort>.+)\sDPT\=(?<DestinationPort>.+)\s.+$/';


    /**
     * php function
     * SOURCE: http://www.php.net/manual/en/language.functions.php
     */
    const PHPFUNC = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*./';

    /**
     * php variable
     * SOURCE: http://www.php.net/manual/en/language.variables.php
     */
    const PHPVAR = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/';

}
// }}}

?>
